﻿@using DPUWebPhet10.Helpers
@model DPUWebPhet10.Models.ApplicationModel
@{
    ViewBag.Title = "รับสมัคร";
    Layout = "~/Views/Shared/_Managementlayout.cshtml";
}
<!-- Box -->
<div class="box">
    <!-- Box Head -->
    <div class="box-head">
        <h2>
            @DPUWebPhet10.Resources.Common.Common.LB007@DPUWebPhet10.Resources.Common.Common.LB013</h2>
    </div>
    @using (Html.BeginForm("Index", "Application", FormMethod.Post))
    {
        @Html.ValidationSummary(true)
        <div class="form">
            @if (@HttpContext.Current.Session["PhetCulture"].ToString().Equals("en"))
            {
                <!-- English Application Form -->
                <p>
                    <!-- School Name -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_NAME)
                    @Html.AutocompleteFor(model => model.school.SCHOOL_NAME, "Autocomplete", "Application")
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_NAME)
                </p>
                <p>
                    <!-- School Type -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_TYPE)
                    @Html.RadioButtonForSelectList(model => model.idSelectedSchoolType, Model.rSchoolTypes)
                </p>
                <p>
                    <!-- Other -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_TYPE_OTHER)
                    @Html.RadioButtonFor(model => model.idSelectedSchoolType, 4, false)
                </p>
                <p>
                    <!-- Address -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR)
                    @Html.TextAreaFor(model => model.school.SCHOOL_ADDR)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR)
                </p>
                <p>
                    <!-- Phone -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_PHONE)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR_PHONE)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_PHONE)
                </p>
                <p>
                    <!-- Fax -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_FAX)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR_FAX)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_FAX)
                </p>
                <p>
                    <!-- Email -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_EMAIL)
                    @Html.EditorFor(model => model.school.SCHOOL_EMAIL)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_EMAIL)
                </p>
            }
            else if (@HttpContext.Current.Session["PhetCulture"].ToString().Equals("zh"))
            {
                <!-- Chaina Application Form -->
                <p>
                    <!-- School Name -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_NAME)
                    @Html.AutocompleteFor(model => model.school.SCHOOL_NAME, "Autocomplete", "Application")
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_NAME)
                </p>
                <p>
                    <!-- Educationi Zone-->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ZONE_EDU)
                    @Html.EditorFor(model => model.school.SCHOOL_ZONE_EDU)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ZONE_EDU)
                </p>
                <p>
                    <!-- Zone-->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ZONE)
                    @Html.EditorFor(model => model.school.SCHOOL_ZONE)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ZONE)
                </p>
                <p>
                    <!-- School Type -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_TYPE)
                    @Html.RadioButtonForSelectList(model => model.idSelectedSchoolType, Model.rSchoolTypes)
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_TYPE_OTHER)
                    @Html.RadioButtonFor(model => model.idSelectedSchoolType, 4, false)
                </p>
                <p>
                    <!-- Other -->
                    @Html.EditorFor(model => model.school.SCHOOL_TYPE_OTHER)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_TYPE_OTHER)
                </p>
                <p>
                    <!-- Address -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR)
                    @Html.TextAreaFor(model => model.school.SCHOOL_ADDR)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR)
                </p>
                <p>
                    <!-- Phone -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_PHONE)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR_PHONE)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_PHONE)
                </p>
                <p>
                    <!-- Fax -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_FAX)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR_FAX)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_FAX)
                </p>
                <p>
                    <!-- Email -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_EMAIL)
                    @Html.EditorFor(model => model.school.SCHOOL_EMAIL)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_EMAIL)
                </p>
            }
            else
            {
                <!-- Thai Application Form -->
                <p>
                    <!-- School Name -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_NAME)
                    @Html.AutocompleteFor(model => model.school.SCHOOL_NAME, "Autocomplete", "Application")
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_NAME)
                </p>
                <p>
                    <!-- Educationi Zone-->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ZONE_EDU)
                    @Html.EditorFor(model => model.school.SCHOOL_ZONE_EDU)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ZONE_EDU)
                </p>
                <p>
                    <!-- Zone-->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ZONE)
                    @Html.EditorFor(model => model.school.SCHOOL_ZONE)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ZONE)
                </p>
                <p>
                    <!-- Province -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_PROVINCE)
                    @Html.DropDownListFor(model => model.school.SCHOOL_PROVINCE, Model.provinceLists, "-- Select --", new { style = "width: 142px" })
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_PROVINCE)
                </p>
                <p>
                    <!-- School Type -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_TYPE)
                    @Html.RadioButtonForSelectList(model => model.idSelectedSchoolType, Model.rSchoolTypes)
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_TYPE_OTHER)
                    @Html.RadioButtonFor(model => model.idSelectedSchoolType, 4, false)
                </p>
                <p>
                    <!-- Other -->
                    @Html.EditorFor(model => model.school.SCHOOL_TYPE_OTHER)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_TYPE_OTHER)
                </p>
                <p>
                    <!-- Address -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR)
                </p>
                <p>
                    <!-- soi -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_SOI)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR_SOI)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_SOI)
                </p>
                <p>
                    <!-- road -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_ROAD)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR_ROAD)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_ROAD)
                </p>
                <p>
                    <!-- Province -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_PROVINCE)
                    @Html.DropDownList("SCHOOL_ADDR_PROVINCE", Model.provinceLists, "-- Select Province --", new { style = "width: 142px" })
                </p>
                <p>
                    <!-- Amphur -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_AMPHUR)
                    <select id="SCHOOL_ADDR_AMPHUR" name="SCHOOL_ADDR_AMPHUR" style="width: 142px">
                    </select>
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_AMPHUR)
                </p>
                <p>
                    <!-- Tombon -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_TOMBON)
                    <select id="SCHOOL_ADDR_TOMBON" name="SCHOOL_ADDR_TOMBON" style="width: 142px">
                    </select>
                </p>
                <p>
                    <!-- Zipcode -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_ZIPCODE)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR_ZIPCODE)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_ZIPCODE)
                </p>
                <p>
                    <!-- Phone -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_PHONE)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR_PHONE)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_PHONE)
                </p>
                <p>
                    <!-- Fax -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_ADDR_FAX)
                    @Html.EditorFor(model => model.school.SCHOOL_ADDR_FAX)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_ADDR_FAX)
                </p>
                <p>
                    <!-- Email -->
                    @Html.Label(@DPUWebPhet10.Resources.Application.Application.SCHOOL_EMAIL)
                    @Html.EditorFor(model => model.school.SCHOOL_EMAIL)
                    @Html.ValidationMessageFor(model => model.school.SCHOOL_EMAIL)
                </p>
        
            }
            <!-- Form Buttons -->
            <div class="buttons">
                <input type="submit" class="button" value="@DPUWebPhet10.Resources.Common.Common.LB002" />
                <input type="submit" class="button" value="@DPUWebPhet10.Resources.Common.Common.LB003" />
            </div>
            <!-- End Form Buttons -->
        </div>
        <!-- End Form -->
    }
</div>
<!-- End Box -->
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")
    @Styles.Render("~/Content/themes/base/css")
    <script type="text/javascript">
        $(document).ready(function () {

            $("#add_staff").click(function () {
                $.ajax({
                    url: "Application/AddStaff",
                    success: function (data) {
                        $("#StaffDiv").append(data);
                        Sys.Mvc.FormContext._Application_Load();
                    }
                });
            });


            $("#add_student").click(function () {
                $.ajax({
                    url: "Application/AddStudent",
                    success: function (data) {
                        $("#StudentDiv").append(data);
                        Sys.Mvc.FormContext._Application_Load();
                    }
                });
            });


            //DELTE STAFF
            $('#StaffDiv').on('click', '.delete-staff', function () {
                $("#StaffDiv_" + $(this).attr("name")).remove();
            });
            //DELETE STUDENT
            $('#StudentDiv').on('click', '.delete-student', function () {
                $("#StudentDiv_" + $(this).attr("name")).remove();
            });


            //Attach cascading behavior to the amphur select element.
            $("#SCHOOL_ADDR_AMPHUR").CascadingDropDown("#SCHOOL_ADDR_PROVINCE", '/Application/AsyncAmphurs',
            {
                promptText: '-- Pick an Amphur --',
                onLoading: function () {
                    $(this).css("background-color", "#ff3");
                },
                onLoaded: function () {
                    $(this).animate({ backgroundColor: '#ffffff' }, 300);
                }
            });

            //Attach cascading behavior to the district select element.
            $("#SCHOOL_ADDR_TOMBON").CascadingDropDown("#SCHOOL_ADDR_AMPHUR", '/Application/AsyncDistricts',
            {
                promptText: '-- Pick District --',
                onLoading: function () {
                    $(this).css("background-color", "#ff3");
                },
                onLoaded: function () {
                    $(this).animate({ backgroundColor: '#ffffff' }, 300);

                }
            });

        });
    </script>
}
